#include <iostream>
using namespace std;

const int N = 100010, M = 131072; //N是输入的数据最多有多少个，M是这些数字二进制化以后，最多需要多少结点来装
int a[N], node[M][2], idx;
int n, ans = 0;

void insert(int x) //将数据以二进制的形式存储trie树中
{
    int p = 0;
    for (int i = 30; i >= 0; --i)
    {
        int u = x >> i & 1;
        if (node[p][u] == 0)
            node[p][u] = ++idx;
        p = node[p][u];
    }
    return;
}

int query(int x) //在把x同数中存的数进行查找，找到x与树中的书对应的最大异或值
{
    int p = 0, res = 0;
    for (int i = 30; i >= 0; --i)
    {
        int u = x >> i & 1;
        if (node[p][!u])
        {
            res += 1 << i;
            p = node[p][!u];
        }
        else
            p = node[p][u];
    }
    return res;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", a + i);
        insert(a[i]);
    }
    for (int i = 0; i < n; ++i)
        ans = max(ans, query(a[i]));
    printf("%d", ans);
}